fix(linear): keep connection through transient check failures#1868
fix(linear): keep connection through transient check failures#1868janburzinski wants to merge 4 commits intogeneralaction:mainfrom
Conversation
…unconnecting-z5bjx # Conflicts: # src/main/core/linear/linear-connection-service.ts
Greptile SummaryThis PR fixes a regression where transient network failures (e.g., losing internet) were treated identically to auth errors, causing Linear to disconnect unnecessarily. The fix introduces a
Confidence Score: 4/5Safe to merge after fixing the dropped optional chaining on One P1 regression: the extracted src/main/core/linear/linear-connection-service.ts — specifically line 124 in
|
| Filename | Overview |
|---|---|
| src/main/core/linear/linear-connection-service.ts | Correctly distinguishes transient failures from auth errors using null sentinel for lastVerifiedDisplayName; fetchViewerDisplayName helper drops the original optional chaining (org?.name → organization.name), which could throw if viewer.organization resolves to null. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[checkConnection called] --> B[getStoredToken]
B -->|no token| C[lastVerifiedDisplayName = null\nreturn connected: false]
B -->|token found| D[fetchViewerDisplayName]
D -->|success| E[lastVerifiedDisplayName = displayName\nreturn connected: true]
D -->|throws| F{isAuthFailure?}
F -->|yes| G[lastVerifiedDisplayName = null\nreturn connected: false + error]
F -->|no transient error| H{lastVerifiedDisplayName === null?}
H -->|yes never verified| I[return connected: false]
H -->|no was previously verified| J[log.warn\nreturn connected: true\ndisplayName: lastVerifiedDisplayName]
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/main/core/linear/linear-connection-service.ts:124
The original call sites used `org?.name` (optional chaining), but the extracted helper removed it. If `viewer.organization` ever resolves to `null` or `undefined`, `organization.name` will throw a `TypeError`. In `saveToken` this would cause a valid token to be rejected with an obscure error message; in `checkConnection` it would be treated as a transient failure. Adding `?.` restores the original defensive behaviour.
```suggestion
return organization?.name ?? viewer.displayName ?? undefined;
```
Reviews (2): Last reviewed commit: "fix(linear): handle verified connections..." | Re-trigger Greptile
|
@greptile review |
| const client = this.getClientForToken(token); | ||
| const viewer = await client.viewer; | ||
| const organization = await viewer.organization; | ||
| return organization.name ?? viewer.displayName ?? undefined; |
There was a problem hiding this comment.
The original call sites used
org?.name (optional chaining), but the extracted helper removed it. If viewer.organization ever resolves to null or undefined, organization.name will throw a TypeError. In saveToken this would cause a valid token to be rejected with an obscure error message; in checkConnection it would be treated as a transient failure. Adding ?. restores the original defensive behaviour.
| return organization.name ?? viewer.displayName ?? undefined; | |
| return organization?.name ?? viewer.displayName ?? undefined; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/main/core/linear/linear-connection-service.ts
Line: 124
Comment:
The original call sites used `org?.name` (optional chaining), but the extracted helper removed it. If `viewer.organization` ever resolves to `null` or `undefined`, `organization.name` will throw a `TypeError`. In `saveToken` this would cause a valid token to be rejected with an obscure error message; in `checkConnection` it would be treated as a transient failure. Adding `?.` restores the original defensive behaviour.
```suggestion
return organization?.name ?? viewer.displayName ?? undefined;
```
How can I resolve this? If you propose a fix, please make it concise.
summary
linear connection auth error and timeout was being handled the same this would cause a disconnect just because i lost internet